<?php


class Sherpa_Model_Order extends WSB_Model
{

	/**
	 * @var array
	 */
	protected $_data = array(
		// sherpa_orders
		'id' => null,
		'feuserId' => null,
		'basketId' => null,
		'orderDate' => null,
		'couponId' => null,
		'subtotal' => null,
		'shipFirstName' => null,
		'shipLastName' => null,
		'shipCompany' => null,
		'shipStreet' => null,
		'shipPoBox' => null,
		'shipZipCode' => null,
		'shipCity' => null,
		'shipCountry' => null,
		'shipPhone' => null,
		'shipEmail' => null,
		'billFirstName' => null,
		'billLastName' => null,
		'billCompany' => null,
		'billStreet' => null,
		'billPoBox' => null,
		'billZipCode' => null,
		'billCity' => null,
		'billCountry' => null,
		'billPhone' => null,
		'billEmail' => null,
		'confirmationOrder' => null,
		'confirmationInternal' => null,
		'medialist' => null,
		'modified' => null,
		'created' => null
	);

	/**
	 * @param array $address
	 * @return void
	 */
	public function setShippingAddress(Sherpa_Model_Address $address)
	{
		$fields = array(
			'shipFirstName', 'shipLastName', 'shipCompany', 'shipStreet',
			'shipPoBox', 'shipZipCode', 'shipCity', 'shipCountry', 'shipPhone',
			'shipEmail'
		);
		foreach($address->toArray() AS $key=>$value) {
			$field = 'ship' . ucfirst($key);
			if(in_array($field, $fields)) {
				$this->$field = $value;
			}
		}
	}

	/**
	 * @param array $address
	 * @return void
	 */
	public function setBillingAddress(Sherpa_Model_Address $address)
	{
		$fields = array(
			'billFirstName', 'billLastName', 'billCompany', 'billStreet',
			'billPoBox', 'billZipCode', 'billCity', 'billCountry', 'billPhone',
			'billEmail'
		);
		foreach($address->toArray() AS $key=>$value) {
			$field = 'bill' . ucfirst($key);
			if(in_array($field, $fields)) {
				$this->$field = $value;
			}
		}
	}

}

